/*
* yasl-qt (or simply yasl) is a qt-based program for symbian devices
* and intended to manage a shopping list.
* The acronym yasl stands for Yet Another Shopping List.
* 
* Copyright (C) 2011 - Alessandro Orlandi
* 
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* 
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
* 
* You should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/


#include "KbdPassiveDisplay.h"

KbdPassiveDisplay::KbdPassiveDisplay(QWidget *parent) :
    QLineEdit(parent)
{
}

void KbdPassiveDisplay::addChars(QString pText)
{

    if (pText.compare("<<")==0)
    {
        deleteChars(1);
    }
    else
    {
        QString lNewtext = text() + pText;
        this->setText(lNewtext);        
        if (pText.compare("") == 0)
            emit textChanged(text());
    }

}

void KbdPassiveDisplay::deleteChars(int pNumOfChars)
{
    if (pNumOfChars > text().length())
        pNumOfChars = text().length();


    if (text().length() > 0)
    {
        QString lTmpText = text();
        lTmpText.truncate(lTmpText.length()-1);
        setText(lTmpText);

    }
}

void KbdPassiveDisplay::reset()
{
    setText("");
}
